package utils

import (
	"chat_gin/entity/dto"
	"github.com/gin-gonic/gin"
	"strconv"
)

// 公用的处理请求数据的地方

// DealPageInfo 处理请求参数分页信息
func DealPageInfo(c *gin.Context) dto.Page {

	pageIndex, err := strconv.Atoi(c.Query("page_index"))
	if err != nil {
		pageIndex = 1
	}
	pageSize, err := strconv.Atoi(c.Query("page_size"))
	if err != nil {
		pageSize = 10
	}
	pageInfo := dto.Page{
		PageIndex: pageIndex,
		PageSize:  pageSize,
	}
	return pageInfo
}
